﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Domain.Logging;

namespace WebUI.Controllers
{
    public abstract class NMCToolControllerBase : Controller
    {
        private LogService _logger;


        protected NMCToolControllerBase(LogService logger)
        {
            _logger = logger;
        }


        protected override void OnException(ExceptionContext filterContext)
        {
            LogException(filterContext.Controller, filterContext.Exception);
            base.OnException(filterContext);
        }

        protected void LogException(object origin, Exception e)
        {
            _logger.WriteError("An error in {1}: {0}", origin.GetType(), e.ToString());
        }

        public LogService LogService
        { get { return _logger; } }
    }
}